<?php

use yii\db\Schema;
use yii\db\Migration;

class m150617_071702_adspace_category_map extends Migration
{
    public function up()
    {
    	$sql = <<<FINE
DROP TABLE IF EXISTS {{%adspace_category_map}};
CREATE TABLE {{%adspace_category_map}} (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  ad_network_id int(10) NOT NULL COMMENT '所属ssp',
  name varchar(128) NOT NULL COMMENT '广告位类目',
  category_id varchar(60) NOT NULL COMMENT '所属ssp 标准id',
  vam_map_id  varchar(60) NOT NULL COMMENT '映射后的id',
  last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

INSERT INTO {{%adspace_category_map}} (ad_network_id, name, category_id, vam_map_id) VALUES 
(2, '返利','2003' ,'17'),
(2,	'休闲娱乐', '40101', '609'),
(2,	'影视', '40102', '601'),
(2,	'音乐', '40201', '602'),
(2,	'笑话',	'40301', '703'),
(2,	'游戏',	'40401', '607'),
(2,	'动漫',	'40501', '6'),
(2,	'IT数码', '40901', '4'),
(2,	'设计', '41003', '8'),
(2,	'男性小说', '41101', '6'),
(2,	'女性小说', '41102', '6'),
(2,	'社区', '41401', '7'),
(2,	'社交', '41404', '7'),
(2,	'生活服务', '41501', '1701'),
(2,	'美食', '41502', '1401'),
(2,	'快递', '41504', '17'),
(2,	'天气', '41505', '1701'),
(2,	'女性时尚', '41601', '1201'),
(2,	'教育', '41706', '8'),
(2,	'综合门户', '41801', '2'),
(2,	'地方门户', '41802', '2'),
(2,	'军事', '41805', '201'),
(2,	'交通旅游', '42004', '11'),
(2,	'健康', '42101', '1005'),
(2,	'母婴', '42103', '1203'),
(2,	'网址站', '42201', '704'),
(2,	'财经', '42401', '3'),
(2,	'导购分享', '42501', '1701'),
(2,	'体育', '42603', '10'),
(2,	'房产家居', '42702', '1701'),
(2,	'垂直行业', '42801', '2'),
(2,	'其他', '42901', '99');


FINE;
		$this->execute($sql);
    }

    public function down()
    {
         $sql = <<<FINE
        DROP TABLE IF EXISTS {{%adspace_category_map}};
FINE;
		$this->execute($sql);

        return false;
    }
}
